/*
 * Copyright (C) 2009 Georgios J. Georgopoulos, All rights reserved.
 * 
 * This is free software; you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option) any
 * later version.
 * 
 * This software is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this software; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
 * site: http://www.fsf.org.
 */
package org.gwt.mosaic.xul.client.ui;

import com.google.gwt.user.client.ui.Widget;

/**
 * A column of a table. It displays the column header and holds the size and
 * other information about the column.
 * 
 * @author georgopoulos.georgios(at)gmail.com
 * 
 */
public class Tablecol extends Element {
  private static final long serialVersionUID = 8378566301011586126L;

  /**
   * Allows the contents of cells in the column to be changed, especially useful
   * when type="checkbox". When the user double-clicks an editable cell, a text
   * field appears in which the user can edit the contents of the cell.
   * <p>
   * NOTE: The table must also be marked as editable in order for this to work.
   * Individual tablecell elements in the column may be marked editable="false"
   * in order to disable editing.
   */
  public static final String EDITABLE = "editable";

  /**
   * If true, the size of the column in the tree cannot be adjusted by the user.
   * Any splitter to either side will resize those columns while keeping the
   * fixed column at a constant size. If false or not specified, the user can
   * adjust the size of the column, typically by dragging the column header with
   * the mouse.
   */
  public static final String FIXED = "fixed";

  /**
   * The label that will appear on the element. If this is left out, no text
   * appears.
   */
  public static final String LABEL = "label";

  /**
   * 
   */
  public static final String SORT = "sort";

  /**
   * The type of table column. The default is a text column that displays the
   * content as text.
   * <p>
   * <li>{@code checkbox}: The content of the columns as checkboxes.</li>
   * <li>{@code progressmeter}: The content of the columns are a progress meter.
   * </li>
   * <li>{@code text}: The content of the columns is text.</li>
   */
  public static final String TYPE = "type";

  public Tablecol() {
    super();
  }

  @Override
  protected Widget createUI() {
    return null;
  }

  public String getLabel() {
    return getString(LABEL);
  }

  public String getType() {
    return getString(TYPE);
  }

  public boolean isEditable() {
    return getBoolean(EDITABLE);
  }

  public boolean isFixed() {
    return getBoolean(FIXED);
  }

  public void setEditable(boolean editable) {
    putBoolean(EDITABLE, editable);
  }

  public void setFixed(boolean fixed) {
    putBoolean(FIXED, fixed);
  }

  public void setLabel(String label) {
    putString(LABEL, label);
  }

  public void setType(String type) {
    putString(TYPE, type);
  }
  
}
